Public API Overview
Welcome to the Eggplant DAI Public API documentation. This guide will help you get started with the public REST API endpoints, enabling you to interact with Eggplant DAI's services. Through the public REST API, you can programmatically access a variety of resources and functionalities offered by Eggplant DAI, such as obtaining access tokens, listing and retrieving test results, and accessing logs for individual tests.
Generate Your API Client Credentials
To use the public API, you need to authenticate and obtain an access token. This token must be included in the header of all subsequent API requests.
Admin users can create API clients, which have permissions equivalent to an admin user, except for creating additional API clients.
To create an API client:
- Visit the Eggplant DAI UI and log in with your admin credentials.
- Navigate to System > API Access.
- Click New API Access.
- Add a name and description for your credentials.
- Click Create.
- When prompted, click Download and store the credentials
.csv
file in a safe place.
You can now use the client_id
and client_secret
variables from your credentials file to acquire an access token.
Treat these credentials as you would a password. Store them securely and do not share them. If API credentials are ever misplaced, leaked, or forgotten, they can be revoked or regenerated through the API Access interface.
Acquire an Access Token and Authenticate
Use the credentials from the previous steps to obtain an access token from the API and authenticate.
Example Request
curl -X POST "https://YOUR_DAI_BASE_URL/api/v1/auth" \
-H "Content-Type: application/json" \
-d '{"client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET"}'
Example Response
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ2U1FaeW9W...",
"expires_in": 600
}
Access Protected API Resource Endpoints
Once authenticated, you can use the valid access token to access protected API resource endpoints. Since the token expires after ten minutes, you must regularly resend your credentials to obtain a new access token.
Example Request
curl -X GET "https://YOUR_DAI_BASE_URL/api/v1/test_results" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"